<template>
	<custom-page title="注销账号" backgroundColor="#F9F9F9">
		<template #page>
			<view class="page-content">
				<image class="tips-img" :src="asserts.ic_write_off"></image>
				<view class="title">注销助叫账号服务</view>
				<view class="content">账号注销后，你将放弃以下权益且无法找回</view>
				<view class="tips-layout">
					<view class="tips-text">1、你将无法通过该账号登录、使用助叫桌球平台服务</view>
					<view class="tips-text">2、你将无法访问账号的个人信息（包括账号名称、昵称、头像、生日等）</view>
					<view class="tips-text">3、你曾通过该账号获得的优惠券或其它卡券、金额、权益等视为你自行放弃</view>
				</view>
				<view class="confirm-btn" @click="confirmWriteOff">确认注销</view>
			</view>
		</template>
	</custom-page>
</template>

<script>
	import {
		storageUserType, storageTokenKey
	} from '../../global/config.js'
	export default {
		data() {
			return {
				userType: '2',	     //用户类型 1 - 普通用户 2 - 助教用户
			}
		},
		onLoad() {
			this.userType = uni.getStorageSync(storageUserType)
		},
		methods: {
			//确认注销
			confirmWriteOff(){
				uni.showModal({
					title: '确定注销吗？',
					success: (modal) => {
						if (modal.confirm) {
							if(this.userType == '2'){
								this.requestCenter.assistantWriteOff().then(res => {
									this.resetUser()
								})
							}else{
								
							}
							
						}
					}
				})
			},
			
			resetUser(){
				uni.setStorageSync(storageTokenKey, '')
				uni.setStorageSync(storageUserType, '')		//用户类型 1 - 普通用户 2 - 助教用户
				uni.reLaunch({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page-content{
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 64rpx 16rpx 0 16rpx;
		box-sizing: border-box;
	}
	.tips-img{
		width: 200rpx;
		height: 200rpx;
	}
	.title{
		font-size: 32rpx;
		color: #021624;
		margin-top: 32rpx;
		line-height: 48rpx;
	}
	.content{
		font-size: 24rpx;
		color: #585F70;
		margin-top: 16rpx;
	}
	.tips-layout{
		width: 100%;
		height: 392rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 32rpx 24rpx;
		box-sizing: border-box;
		margin-top: 32rpx;
		.tips-text{
			font-size: 28rpx;
			color: #585F70;
			margin-bottom: 32rpx;
			line-height: 48rpx;
		}
		.tips-text:last-child{
			margin-bottom: 0rpx;
		}
	}
	.confirm-btn{
		width: 718rpx;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		background: #ED3C3D;
		border-radius: 50rpx;
		margin-top: 40rpx;
		font-size: 28rpx;
		color: #FFFFFF;
	}
	
</style>
